<template>
  <div>
    <el-divider>行政信息</el-divider>
    <el-form-item style="margin-left: 0">
      <el-row type="flex" :gutter="20" align="middle">
        <el-col :span="6">
          <el-form-item label="资料是否齐全" label-width="100px">
            <el-select v-model="reportCommonObj.administrativeCompleteMaterial" style="width: 100%">
              <el-option
                v-for="item in scrap"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="是否归档">
            <el-select v-model="reportCommonObj.administrativeFile" style="width: 100%">
              <el-option
                v-for="item in scrap"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="存档时间">
            <el-date-picker
              v-model="reportCommonObj.administrativeFileDate"
              value-format="timestamp"
              style="width: 100%"
              type="date"
              placeholder="选择日期"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="是否作废">
            <el-select v-model="reportCommonObj.administrativeCancellation">
              <el-option
                v-for="item in scrap"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex" :gutter="20" align="middle">
        <el-col :span="12">
          <el-form-item label="未存档原因" label-width="100px">
            <el-input v-model="reportCommonObj.administrativeCause" type="textarea" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="备注" label-width="100px">
            <el-input v-model="reportCommonObj.administrativeRemark" type="textarea" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row type="flex" :gutter="20" align="middle">
        <el-col :span="1">
          <el-form-item label-width="0px">
            <el-button type="primary" :disabled="reportStatus != 6" @click="toFile">归档</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form-item>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import {
  auditToFile
} from '@/api/project-report'

export default {
  name: 'AdministrativeInfo',
  props: {
    reportCommonObj: {
      type: Object,
      required: true
    },
    reportStatus: {
      type: Object,
      required: true
    },
    isAudit: {
      type: Boolean,
      default: false,
      required: true
    },
    auditLeaf: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      fileTime: '',
      scrap: [{
        value: '是',
        label: '是'
      }, {
        value: '否',
        label: '否'
      }]
    }
  },

  computed: {
    ...mapGetters([
      'id'
    ])
  },

  methods: {
    toFile() {
      const id = this.$route.query.id
      this.$confirm('请确保已保存页面上的信息,归档后将不可修改.', '归档申请', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        auditToFile(id, this.id).then(res => {
          this.$message.success(res.message)
          this.$router.go(0)
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
